# Dismiss Recommended Accounts Scripts This repository contains PowerShell scripts for managing CyberArk accounts marked for deletion: - **Auto-Dismiss.ps1** - Automatically dismisses all accounts with the `DeleteInsightStatus` filter - **Export-Accounts.ps1** - Exports accounts marked for deletion to CSV - **Process-Accounts.ps1** - Processes accounts from the CSV with actions (DISMISS/DELETE/SKIP) ## Prerequisites - PowerShell 7 or higher - CyberArk Privileged Cloud PVWA access - Vault/Built-In Admin User, with appropriate permissions to: - View accounts - Update account file categories - Delete accounts (for Process-Accounts.ps1) ## Scripts Overview ### Auto-Dismiss.ps1 - Auto-Dismiss All Accounts Automatically dismisses all accounts with the `DeleteInsightStatus` filter by updating the file category to `Dismissed`. ### Export-Accounts.ps1 - Export Accounts to CSV Exports accounts marked for deletion to a CSV file with the columns: `AccountID`, `UserName`, `Address`, `Safe`, `PlatformName`. ### Process-Accounts.ps1 - Process Accounts from CSV Reads accounts from CSV and processes them with the following actions: - **DISMISS** - Update `DeleteInsightStatus` file category to `Dismissed` - **DELETE** - Delete the account - **SKIP** - Skip the account ## Usage ### Standard Environment (Interactive Authentication) For standard CyberArk Privilege Cloud environments: ```powershell # Auto-dismiss all accounts .\Auto-Dismiss.ps1 -PCloudURL "https://tenant.privilegecloud.cyberark.cloud/passwordvault" -IdentityUserName "your-username" # Export accounts to CSV .\Export-Accounts.ps1 -PCloudURL "https://tenant.privilegecloud.cyberark.cloud/passwordvault" -IdentityUserName "your-username" # Process accounts from CSV .\Process-Accounts.ps1 -PCloudURL "https://tenant.privilegecloud.cyberark.cloud/passwordvault" -IdentityUserName "your-username" ``` This will prompt you for your password and any MFA challenges. ### Using the Credentials Object ```powershell $creds = Get-Credential .\Auto-Dismiss.ps1 -PCloudURL "https://tenant.privilegecloud.cyberark.cloud/passwordvault" -UPCreds $creds ``` ### Using OAuth (Client Credentials) ```powershell $oauthCreds = Get-Credential # Username = Client ID, Password = Client Secret .\Auto-Dismiss.ps1 -PCloudURL "https://tenant.privilegecloud.cyberark.cloud/passwordvault" -OAuthCreds $oauthCreds ``` ### WhatIf Mode (Dry Run) - Auto-Dismiss.ps1 only To see what would be updated without making changes: ```powershell .\Auto-Dismiss.ps1 -PCloudURL "https://tenant.privilegecloud.cyberark.cloud/passwordvault" -IdentityUserName "your-username" -WhatIf ``` ### Limiting Number of Accounts - Auto-Dismiss.ps1 and Export-Accounts.ps1 ```powershell .\Auto-Dismiss.ps1 -PCloudURL "https://tenant.privilegecloud.cyberark.cloud/passwordvault" -IdentityUserName "your-username" -Limit 100 .\Export-Accounts.ps1 -PCloudURL "https://tenant.privilegecloud.cyberark.cloud/passwordvault" -IdentityUserName "your-username" -Limit 100 ``` ### Export-Accounts.ps1 - Custom CSV Path ```powershell .\Export-Accounts.ps1 -PCloudURL "https://tenant.privilegecloud.cyberark.cloud/passwordvault" -IdentityUserName "your-username" -CSVPath "C:\path\to\output.csv" ``` ### Process-Accounts.ps1 - Custom CSV Path ```powershell .\Process-Accounts.ps1 -PCloudURL "https://tenant.privilegecloud.cyberark.cloud/passwordvault" -IdentityUserName "your-username" -CSVPath "C:\path\to\Accounts.csv" ``` ### Process-Accounts.ps1 - Action Column in CSV If your CSV has an `Action` column, the script will: - Process accounts with actions automatically (DISMISS/DELETE/SKIP) - Prompt once for the default action for accounts without an action - If no `Action` column exists, prompts once for the default action for all accounts Example CSV with the Action column: ```csv AccountID,UserName,Address,Safe,PlatformName,Action 123_45,admin,1.1.1.1,Safe1,Windows,DISMISS 123_46,user,2.2.2.2,Safe2,Linux,DELETE 123_47,guest,3.3.3.3,Safe3,Windows,SKIP ``` ## Parameters ### Common Parameters (All Scripts) - **PCloudURL** (Required): The base URL of your Privilege Cloud PVWA environment, including the `/passwordvault` path - example: `https://tenant.privilegecloud.cyberark.cloud/passwordvault` - **IdentityUserName** (Optional): Username for authentication. Will prompt for password and MFA if needed. - **UPCreds** (Optional): PSCredential object containing username and password. - **OAuthCreds** (Optional): PSCredential object containing OAuth Client ID (username) and Client Secret (password). ### Script-Specific Parameters #### Auto-Dismiss.ps1 - **Limit** (Optional): Maximum number of accounts to process. Default is 1000. - **WhatIf** (Optional): Shows what would be updated without making actual changes. #### Export-Accounts.ps1 - **CSVPath** (Optional): Path to the CSV file to export. Default is `Accounts.csv` in script location. - **Limit** (Optional): Maximum number of accounts to retrieve. Default is 1000. #### Process-Accounts.ps1 - **CSVPath** (Optional): Path to the CSV file to read. Default is `Accounts.csv` in script location. ## What Each Script Does ### Auto-Dismiss.ps1 1. **Authenticates** with Privilege Cloud PVWA using the IdentityAuthv2 module 2. **Retrieves accounts** filtered by `SavedFilter=DeleteInsightStatus` 3. **Updates** the `DeleteInsightStatus` file category to `Dismissed` for each account 4. **Reports** a summary of successful and failed updates ### Export-Accounts.ps1 1. **Authenticates** with Privilege Cloud PVWA using the IdentityAuthv2 module 2. **Retrieves accounts** filtered by `SavedFilter=DeleteInsightStatus` 3. **Exports** accounts to CSV with columns: `AccountID`, `UserName`, `Address`, `Safe`, `PlatformName` 4. **Reports** export completion ### Process-Accounts.ps1 1. **Authenticates** with Privilege Cloud PVWA using the IdentityAuthv2 module 2. **Reads accounts** from CSV file 3. **Processes each account** based on action: - If the CSV has `Action` column: Uses the action from the CSV, prompts once for default action for accounts without action - If the CSV has no `Action` column: Prompts once for the default action and applies it to all accounts 4. **Executes actions**: DISMISS (update file category), DELETE (delete account), or SKIP (skip account) 5. **Reports** a summary of actions taken ## Output ### Auto-Dismiss.ps1 - Progress information for each step - Details for each account being processed - A summary showing: - Total accounts processed - Successfully updated accounts - Failed updates (if any exist) ### Export-Accounts.ps1 - Progress information for each step - CSV file location and total accounts exported ### Process-Accounts.ps1 - Progress information for each step - Details for each account being processed with the action taken - A summary showing: - Total accounts processed - Dismissed count - Deleted count - Skipped count - Failed count